"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatTime = void 0;
var formatTime = function (date) {
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    var hour = date.getHours();
    var minute = date.getMinutes();
    var second = date.getSeconds();
    return ([year, month, day].map(formatNumber).join('/') +
        ' ' +
        [hour, minute, second].map(formatNumber).join(':'));
};
exports.formatTime = formatTime;
var formatNumber = function (n) {
    var s = n.toString();
    return s[1] ? s : '0' + s;
};
export function getColor() {
    const colors = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F']
    let index = 0;
    let color = '#';
    while (index < 6) {
        color += colors[parseInt(Math.random() * 16)];
        index += 1
    }
    return color;
}
exports.productRandom = function (id) {
    return {
        id,
        title: `年轮${id}（6人本）`,
        price: "130",
        tags: [{ tag: '决斗', color: getColor() }, { tag: '硬核', color: getColor() }, { tag: '烧脑', color: getColor() }],
        time: '2021-01-20 12:00',
        address: '中央大街',
        status: 1,
        male: [3, 5],
        female: [1, 4],
        isCollection: id % 2 === 0 ? true : false
    }
}
exports.formatTime = function dateFormat(fmt, date) {
    let ret;
    const opt = {
        "Y+": date.getFullYear().toString(),        // 年
        "m+": (date.getMonth() + 1).toString(),     // 月
        "d+": date.getDate().toString(),            // 日
        "H+": date.getHours().toString(),           // 时
        "M+": date.getMinutes().toString(),         // 分
        "S+": date.getSeconds().toString()          // 秒
        // 有其他格式化字符需求可以继续添加，必须转化成字符串
    };
    for (let k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
            fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
        };
    };
    return fmt;
}